package com.liuyang.demo;

public class base {
    public static void main(String[] args) {
        byte[] bytes = intToBytes(1);
        System.out.println(bytes);
    }
    public static byte[] intToBytes(int n) {
        //长度4字节的数组
        byte[] buf = new byte[4];
        for (int i = 0; i < buf.length; i++) {
            //循环右移动8位，存储到数组中
            System.out.println(n >> (8 * i));
            buf[i] = (byte) (n >> (8 * i));
        }
        return buf;
    }
}
